<?php

namespace App\Services\Product;

use App\Models\Config;
use App\Exceptions\ConfigException;

class ConfigService
{
    /**
     * 根据字段条件获取第一个模型数据
     * @param   $attribute 
     * @param   $value     
     * @param  array  $columns   
     * @return             
     */
    public function getBy($attribute, $value, $columns = array('*'))
    {
        return Config::where($attribute, '=', $value)->first($columns);
    }

    public function addPrice($data)
    {
        try{
            Config::create($data);
        }catch(Exception $e){
            throw new ConfigException('price');
        }
    }

    public function addBindMessage($data)
    {
        try{
            Config::create($data);
        }catch(Exception $e){
            throw new ConfigException('bindMessage');
        }
    }


}